package com.chinasofti.map;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class DemoMap01 {
    public static void main(String[] args) {
        Map<String,String> map = new HashMap<>();
        map.put("k1","v1");
        map.put("k2","v2");
//        nethod1(map);
//        method2(map);
//        method3(map);
//        method4(map);
//         System.out.println(map.containsValue("v1"));

//        map.clear();
//        System.out.println(map.isEmpty() );
//        method5(map);
        Collection<String> valus = map.values();
        for (String str : valus)
            System.out.println(str);
        Collection<String> k = map.keySet();
        for (String str : k)
            System.out.println(str);
    }

    private static void method5(Map<String, String> map) {
        System.out.println(map.size() );
        Set<String> stringSet = map.keySet();
        for (String str : stringSet)
            System.out.println(str);
    }

    private static void method4(Map<String, String> map) {
        boolean b1 = map.containsKey("k2");
        System.out.println(b1);
    }

    private static void method3(Map<String, String> map) {
        map.clear();
        System.out.println(map);
    }

    private static void method2(Map<String, String> map) {
        String k1 = map.remove("k1");
        System.out.println(k1);
    }


    private static void nethod1(Map<String, String> map) {
        String s = map.put("k2","v3");
        System.out.println(s);
        System.out.println(map);
    }
}
